package 异常;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FinallyDemo {
    public static void main(String[] args) {
        FileOutputStream fos=null;

        try {
            fos=new FileOutputStream("note.txt");
        } catch (FileNotFoundException e) {
            e.printStackTrace();//将错误信息输出到控制台
        } finally {
            try {
                if (fos!=null){
                    fos.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
